import {
  adjustHomePCFontSize,
  checkIsMobile,
  clientLess800,
} from '@/utils';
import { useDebounce, useSize } from 'ahooks';
import { useEffect, useMemo } from 'react';

export const useIsMobile = () => {
  const size = useSize(document.querySelector('body'));
  const debouncedValue = useDebounce(size, { wait: 300 });

  useEffect(() => {
    adjustHomePCFontSize();
  }, [debouncedValue]);

  const showMobileCom = useMemo(() => {
    return checkIsMobile() || clientLess800();
  }, [debouncedValue]);

  return showMobileCom;
};
